﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Xml.Linq;
using System.Collections.Generic;
using System.Linq;

namespace CanalDeNoticiasMSDNv4.ViewModels
{
    public class ElementoEntradaRss
    {
        public string Guid { get; set; }
        public string Title { get; set; }
        public string Link { get; set; }
        public string Description { get; set; }
        public string PubDate { get; set; }

        public static List<ElementoEntradaRss> GetElements(string response)
        {
            var rssFeed = XElement.Parse(response);
            var channel = rssFeed.Descendants("channel");


            var elementos = (from item in channel.Elements("item")
                             select new ElementoEntradaRss
                             {
                                 Guid = item.Element("guid").Value,
                                 Title = item.Element("title").Value,
                                 Link = item.Element("link").Value,
                                 Description = item.Element("description").Value,
                                 PubDate = item.Element("pubDate").Value
                             });

            return elementos.ToList();
        }
    }
}
